
//
//  WorkerResumeDetailViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/31.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "WorkerResumeDetailViewController.h"
#import "WorkerResumeInfoModel.h"
#import "ResumeWorkCell.h"
#import "PayWalletModel.h"
#import "WorkerChatSettingViewController.h"
#import "WorkerResumeSettingViewController.h"
#import "InviteReexamineViewController.h"
#import "ShowImgView.h"
#import "CompanyJobModel.h"

#import "CompanyHomeViewController.h"
#import "CTransitionToPListVC.h"

@interface WorkerResumeDetailViewController ()<ShowImgViewDelegate, UINavigationControllerDelegate>
{
    WorkerResumeInfoModel *infoModel;
    PayWalletModel *payInfoModel;
    
    UIScrollView *bottomScrollView;
    UIBarButtonItem *collect;
    
    ShowImgView *showImgView;
}
@property (nonatomic, strong) UIPercentDrivenInteractiveTransition *interactivePopTransition;
@end

@implementation WorkerResumeDetailViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.delegate = self;
    
//    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.navigationController.delegate == self) {
        self.navigationController.delegate = nil;
    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    // 返回手势
//    UIPanGestureRecognizer *popRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePopRecognizer:)];
//    [self.view addGestureRecognizer:popRecognizer];
    
    if (self.canShowImg) {
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(lookImg:) name:NotificationFor_Resume_LookImg object:nil];
    }
    
    if (!self.bgColor) {
        self.bgColor = THEMECOLOR_OF_ORANGE;
    }
    
    if (self.showChatSettingFlag) {
       self.navigationItem.title = @"人才简历";
    } else {
       self.navigationItem.title = @"人才详情";
    }
    [self loadData];
    [self loadDataPayWallet];
}
- (void)loadData {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:self.id forKey:@"resume_id"];
    
    [BaseNetManager requestWithMethod:POST path:Company_GetResumeDetail_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            self->infoModel = [[WorkerResumeInfoModel alloc] init];
            [self->infoModel setValuesForKeysWithDictionary:data];
            self->infoModel.auth_info = responseObject[@"data"][@"auth_info"];
            [self initUI];
            SVPHUDDismiss;
        } else if ([responseObject[@"code"] integerValue] == 1400) {
            SVPHUDError(responseObject[@"msg"]);
            [self.navigationController popViewControllerAnimated:YES];
        } else {
            [self.navigationController popViewControllerAnimated:YES];
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)loadDataPayWallet {
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [BaseNetManager requestWithMethod:POST path:Company_GetPayWallet_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            self->payInfoModel = [[PayWalletModel alloc] init];
            [self->payInfoModel setValuesForKeysWithDictionary:data];
        }
    } failurBlock:^(NSError * _Nonnull error) {
        [self loadDataPayWallet];
    }];
}
- (void)collectTap {
    if (Signin) {
        NSLog(@"collectTap");
        NSString *url = Company_FavoriteResume_URL;
        if ([infoModel.favorite_status integerValue]) { // 已关注
            url = Company_CancelFavoriteResume_URL;
        } else { // 未关注
            url = Company_FavoriteResume_URL;
        }
        NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
        dic = [UIToolsControl getPublicParameter];
        [dic setObject:self.id forKey:@"resume_id"];
        
        [BaseNetManager requestWithMethod:POST path:url params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
            if ([responseObject[@"code"] integerValue] == 2000) {
                SVPHUDSuccess(responseObject[@"msg"]);
                if ([self->infoModel.favorite_status integerValue]) {
                    self->infoModel.favorite_status = @"0";
                } else {
                    self->infoModel.favorite_status = @"1";
                }
                self->collect = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:(([self->infoModel.favorite_status integerValue])?@"collect_icon_s":@"collect_icon")] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(collectTap)];
                self.navigationItem.rightBarButtonItem = self->collect;
            } else {
                SVPHUDError(responseObject[@"msg"]);
            }
        } failurBlock:^(NSError * _Nonnull error) {
            SVPHUDError(NetErrorAlertText);
        }];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
        }];
    }
}
- (void)chatBtnTap {
    NSLog(@"聊天");
    if (Signin) {
//        [self gotoChat];
        [self gotoChatForCheckout];
    } else {
        __weak __typeof(self)weakSelf = self;
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            __strong __typeof(weakSelf)strongSelf = weakSelf;
//            [strongSelf gotoChat];
            [strongSelf gotoChatForCheckout];
        }];
    }
}
- (void)gotoChatForCheckout {
    if ([DataToolsControl sharedManager].validJob) {
        [self gotoChat];
    } else {
        CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:@"您还没有通过审核的职位，职位审核通过后，再进行沟通" prompt:nil sureBtn:@"确认" cancleBtn:@"取消" size:200];
//        __weak __typeof(self)weakSelf = self;
        alertView.resultIndex = ^(NSInteger index){ //回调---处理一系列动作
//            __strong __typeof(weakSelf)strongSelf = weakSelf;
//            if (index == 2) {
//                [strongSelf gotoChat];
//            }
        };
        [alertView showXLAlertView];
    }
}
- (void)gotoChat {
    if ([infoModel.chat_status integerValue] == 1) { // 可沟通
        [self pushChatVC];
    } else { // 需付费
        CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"尊敬的企业您好，沟通该高级认证人才需支付%@聘豆", infoModel.price] prompt:nil sureBtn:@"立即支付" cancleBtn:@"取消" size:200];
        __weak __typeof(self)weakSelf = self;
        alertView.resultIndex = ^(NSInteger index) { //回调---处理一系列动作
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            if (index == 2) {
                [strongSelf getChatQual];
            }
        };
        [alertView showXLAlertView];
    }
}
#pragma mark - 聊天-获得沟通资格
- (void)getChatQual {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:infoModel.userid forKey:@"target_uid"];
    [BaseNetManager requestWithMethod:POST path:Company_GetChatQual_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            NSString *trade_sn = [NSString stringWithFormat:@"%@", data[@"trade_sn"]];
//            NSString *expire_time = data[@"expire_time"];
            NSMutableDictionary *dic111 = [NSMutableDictionary dictionaryWithCapacity:0];
            dic111 = [UIToolsControl getPublicParameter];
            [dic111 setObject:trade_sn forKey:@"trade_sn"];
            [dic111 setObject:@"coins" forKey:@"payment"];
            [BaseNetManager requestWithMethod:POST path:H5_payTrade_URL params:dic111 successBlock:^(NSDictionary * _Nonnull responseObject) {
                if ([responseObject[@"code"] integerValue] == 2000) {
                    SVPHUDSuccess(responseObject[@"msg"]);
                    [self pushChatVC];
                } else {
                    SVPHUDError(responseObject[@"msg"]);
                }
            } failurBlock:^(NSError * _Nonnull error) {
                SVPHUDError(NetErrorAlertText);
            }];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)pushChatVC {
    TConversationCellData *data = [[TConversationCellData alloc] init];
    data.convId = infoModel.userid;
    data.btpin_user_id = infoModel.userid;
    data.convType = TConv_Type_C2C;
    data.title = infoModel.name;
    ChatViewController *chat = [[ChatViewController alloc] init];
    chat.isNotice = NO;
    chat.isSessionPush = NO;
    chat.conversation = data;
    chat.user_name = infoModel.name;
    chat.job_id = self.job_id;
    chat.job_cn = self.job_cn;
    chat.wage_cn = @"";
    [self.navigationController pushViewController:chat animated:YES];
}
- (void)yuemianshiTap { // 约面试
    InviteReexamineViewController *IRVC = [[InviteReexamineViewController alloc] init];
    IRVC.job_id = self.job_id;
    IRVC.apply_id = self.toudi_id;
    IRVC.user_id = self.user_id;
    IRVC.user_name = self.user_name;
    IRVC.job_cn = self.job_cn;
    IRVC.wage_cn = self.wage_cn;
    [self.navigationController pushViewController:IRVC animated:YES];
}
- (void)shezhiTap { // 简历设置
    WorkerResumeSettingViewController *WRSVC = [[WorkerResumeSettingViewController alloc] init];
    WRSVC.user_id = infoModel.userid;
    WRSVC.user_name = infoModel.name;
    WRSVC.user_headerImg = infoModel.avatar;
    WRSVC.toudi_id = self.toudi_id;
    [self.navigationController pushViewController:WRSVC animated:YES];
}
- (void)showImgViewCancel:(ShowImgView *)shareView {
    shareView.hidden = YES;
}
- (void)headerImgViewTapGesClick {
    showImgView.hidden = NO;
    [showImgView reloadDataForImg:infoModel.avatar];
}
- (void)wxQRImgViewTapGesClick {
    showImgView.hidden = NO;
    [showImgView reloadDataForImg:infoModel.weixin_img];
}
- (void)lookImg:(NSNotification *)notification {
    showImgView.hidden = NO;
    [showImgView reloadDataForImg:notification.userInfo[@"url"]];
}
- (void)initUI {
    if (self.showChatSettingFlag) {
        UIBarButtonItem *yuemianshi = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"duihua_yaoyuexin"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(yuemianshiTap)];
        UIBarButtonItem *shezhi = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"duihua_shezhi"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(shezhiTap)];
        self.navigationItem.rightBarButtonItems = @[shezhi, yuemianshi];
    } else {
        collect = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:(([infoModel.favorite_status integerValue])?@"collect_icon_s":@"collect_icon")] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(collectTap)];
        self.navigationItem.rightBarButtonItem = collect;
    }
    
    bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar-50*Scale)];
    [self.view addSubview:bottomScrollView];
    
    UIView *bottomView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(bottomScrollView), WIDTH, 50*Scale) backgroundColor:COLOR_OF_WHITE];
    [self.view addSubview:bottomView];
    [bottomView borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeTop];
    UIButton *chatBtn = [UIToolsControl initButtonWithFrame:CGRectMake(15*Scale, 5*Scale, WIDTH-30*Scale, 40*Scale) imageName:nil target:self action:@selector(chatBtnTap) title:(self.showChatSettingFlag?@"继续沟通":@"立即沟通") titleColor:COLOR_OF_WHITE];
    chatBtn.layer.cornerRadius = 5*Scale;
    chatBtn.layer.masksToBounds = YES;
    chatBtn.backgroundColor = self.bgColor;
    chatBtn.titleLabel.font = Font(Font_18);
    [bottomView addSubview:chatBtn];
    
    NSMutableArray *array = [NSMutableArray array];
    NSInteger realname = [infoModel.auth_info[@"realname"] integerValue];
    if (realname == 1) {
        NSDictionary *dic = @{@"name":@"实名已认证", @"icon":@"renzehng-shiming_c"};
        [array addObject:dic];
    }
    NSInteger avatar = [infoModel.auth_info[@"avatar"] integerValue];
    if (avatar == 1) {
        if ([infoModel.sex isEqualToString:@"2"]) {
            NSDictionary *dic = @{@"name":@"头像已认证", @"icon":@"renzheng_touxiang_nv_c"};
            [array addObject:dic];
        } else {
            NSDictionary *dic = @{@"name":@"头像已认证", @"icon":@"renzheng-touxiang_c"};
            [array addObject:dic];
        }
    }
    NSInteger education = [infoModel.auth_info[@"education"] integerValue];
    if (education == 1) {
        NSDictionary *dic = @{@"name":@"学历已认证", @"icon":@"renzheng-xueli_c"};
        [array addObject:dic];
    }
    NSInteger work = [infoModel.auth_info[@"work"] integerValue];
    if (work == 1) {
        NSDictionary *dic = @{@"name":@"职业已认证", @"icon":@"renzhneg-zhiye_c"};
        [array addObject:dic];
    }
    
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
    headerView.backgroundColor = [UIColor orangeColor];
    [bottomScrollView addSubview:headerView];
    CGFloat topSpaceHeight = 0;
    if (self.showChatSettingFlag) { // 显示头部
        UILabel *wageLabel = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-110, 0, 100, 40) text:[NSString stringWithFormat:@"薪资:%@", self.wage_cn] textColor:COLOR_OF_WHITE font:Font_13];
        wageLabel.textAlignment = NSTextAlignmentRight;
        wageLabel.adjustsFontSizeToFitWidth = YES;
        [headerView addSubview:wageLabel];
        
        UILabel *jobLabel = [UIToolsControl initLabelWithFrame:CGRectMake(15, 0, wageLabel.left - 20, 40) text:[NSString stringWithFormat:@"当前应聘职位:%@", self.job_title] textColor:COLOR_OF_WHITE font:Font_13];
        jobLabel.adjustsFontSizeToFitWidth = YES;
        [headerView addSubview:jobLabel];
        if (array.count) {
            headerView.height = 80;
            UIView *bottomBack = [[UIView alloc] initWithFrame:CGRectMake(0, 40, WIDTH, 40)];
            bottomBack.backgroundColor = RGB(247, 247, 247);
            [headerView addSubview:bottomBack];

            CGFloat width = (WIDTH - 30)/4;
            for (NSInteger i = 0; i < array.count; i++) {
                UIButton *cerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                cerBtn.tag = 1000+i;
                cerBtn.frame = CGRectMake(15+width*i, 0, width, 40);
                [bottomBack addSubview:cerBtn];
                cerBtn.titleLabel.font = [UIFont systemFontOfSize:12];
                [cerBtn setTitleColor:RGB(85, 85, 85) forState:UIControlStateNormal];
                NSDictionary *dic = array[i];
                [cerBtn setTitle:dic[@"name"] forState:UIControlStateNormal];
                [cerBtn setImage:[UIImage imageNamed:dic[@"icon"]] forState:UIControlStateNormal];
                cerBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -3, 0, 0);
            }
        } else {
           headerView.height = 40;
        }
    } else {
        if (array.count) {
            headerView.height = 40;
            UIView *bottomBack = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
            bottomBack.backgroundColor = RGB(247, 247, 247);
            [headerView addSubview:bottomBack];
            
            CGFloat width = (WIDTH - 30)/4;
            for (NSInteger i = 0; i < array.count; i++) {
                UIButton *cerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                cerBtn.tag = 1000+i;
                cerBtn.frame = CGRectMake(15+width*i, 0, width, 40);
                [bottomBack addSubview:cerBtn];
                cerBtn.titleLabel.font = [UIFont systemFontOfSize:12];
                [cerBtn setTitleColor:RGB(85, 85, 85) forState:UIControlStateNormal];
                NSDictionary *dic = array[i];
                [cerBtn setTitle:dic[@"name"] forState:UIControlStateNormal];
                [cerBtn setImage:[UIImage imageNamed:dic[@"icon"]] forState:UIControlStateNormal];
                cerBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -3, 0, 0);
            }
        } else {
            headerView.height = 0.00001;
            topSpaceHeight = ScalePS(10);
        }
    }
    
//    UIView *topBgView = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, EndY(headerView), WIDTH-60, 95*Scale) backgroundColor:COLOR_OF_WHITE];
    self.bgView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(15), EndY(headerView), WIDTH-ScalePS(30), 210*Scale) backgroundColor:COLOR_OF_WHITE];
    self.bgView.layer.cornerRadius = ScalePS(8);
    self.bgView.layer.masksToBounds = YES;
    [bottomScrollView addSubview:self.bgView];
    
    UIView *topBgView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(15), EndY(headerView)+topSpaceHeight, WIDTH-ScalePS(30), 210*Scale) backgroundColor:self.bgColor];
    topBgView.layer.cornerRadius = ScalePS(8);
    topBgView.layer.masksToBounds = YES;
    [bottomScrollView addSubview:topBgView];
//    [topBgView borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeBottom];
    CGFloat nameWidth = [UIToolsControl textWidth:infoModel.name size:CGSizeMake(MAXFLOAT, 35*Scale) font:Font_27]+10*Scale;
    UILabel *nameLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(20), 15*Scale, nameWidth, 35*Scale) text:infoModel.name textColor:COLOR_OF_WHITE font:Font_27];
    nameLbl.font = FontBold(Font_27);
    [topBgView addSubview:nameLbl];
    
//    UILabel *baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(nameLbl), EndY(nameLbl), 260*Scale, 25*Scale) text:[NSString stringWithFormat:@"%@ %@ %@ %@", infoModel.residence, infoModel.age, infoModel.education_cn, infoModel.experience_cn] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    NSString *baseInfoStr = @"";
    if (infoModel.educationArray && infoModel.educationArray.count) {
        PMineResumeEducationInfoModel *tempModel = infoModel.educationArray[0];
        baseInfoStr = [NSString stringWithFormat:@"%@ %@", infoModel.education_cn, tempModel.school];
    } else {
        baseInfoStr = infoModel.education_cn;
    }
    UILabel *baseInfoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(nameLbl), EndY(nameLbl), 260*Scale, 25*Scale) text:baseInfoStr textColor:COLOR_OF_WHITE font:Font_13];
    [topBgView addSubview:baseInfoLbl];
    
//    UIImageView *headerImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ViewWidth(topBgView)-66*Scale, 20*Scale, 66*Scale, 66*Scale) imageName:@"header_bg"];
    UIImageView *headerImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ViewWidth(topBgView)-80*Scale, 15*Scale, 60*Scale, 60*Scale) imageName:@"header_bg"];
    headerImgView.contentMode = UIViewContentModeScaleAspectFill;
    headerImgView.layer.cornerRadius = 30*Scale;
    headerImgView.layer.masksToBounds = YES;
    headerImgView.userInteractionEnabled = NO;
    [topBgView addSubview:headerImgView];
    if (infoModel.avatar && infoModel.avatar.length) {
        [headerImgView sd_setImageWithURL:[NSURL URLWithString:infoModel.avatar]];
        if (self.canShowImg) {
            headerImgView.userInteractionEnabled = YES;
            UITapGestureRecognizer *headerImgViewTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headerImgViewTapGesClick)];
            [headerImgView addGestureRecognizer:headerImgViewTapGes];
        }
    }
    
    UIView *topBgLineView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(20), ScalePS(80), ViewWidth(topBgView)-ScalePS(40), lineH) backgroundColor:THEMECOLOR_OF_Line_Color];
    [topBgView addSubview:topBgLineView];
    
    UIImageView *birImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(20), EndY(topBgLineView)+ScalePS(12), ScalePS(17), ScalePS(17)) imageName:@"resume_p_bir_icon"];
    birImgView.contentMode = UIViewContentModeScaleAspectFill;
    [topBgView addSubview:birImgView];
    CGFloat birWidth = [UIToolsControl textWidth:[NSString stringWithFormat:@"%@岁", infoModel.age] size:CGSizeMake(MAXFLOAT, ScalePS(17)) font:Font_12]+ScalePS(15);
    UILabel *birLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(birImgView)+ScalePS(5), StartY(birImgView), birWidth, ScalePS(17)) text:[NSString stringWithFormat:@"%@岁", infoModel.age] textColor:COLOR_OF_WHITE font:Font_12];
    [topBgView addSubview:birLbl];
    
    UIImageView *addImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(EndX(birLbl), EndY(topBgLineView)+ScalePS(12), ScalePS(17), ScalePS(17)) imageName:@"resume_p_add_icon"];
    addImgView.contentMode = UIViewContentModeScaleAspectFill;
    [topBgView addSubview:addImgView];
    CGFloat addWidth = [UIToolsControl textWidth:infoModel.residence size:CGSizeMake(MAXFLOAT, ScalePS(17)) font:Font_12]+ScalePS(15);
    UILabel *addLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(addImgView)+ScalePS(5), StartY(addImgView), addWidth, ScalePS(17)) text:infoModel.residence textColor:COLOR_OF_WHITE font:Font_12];
    [topBgView addSubview:addLbl];
    
    UIImageView *expImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(EndX(addLbl), EndY(topBgLineView)+ScalePS(12), ScalePS(17), ScalePS(17)) imageName:@"resume_p_exp_icon"];
    expImgView.contentMode = UIViewContentModeScaleAspectFill;
    [topBgView addSubview:expImgView];
    UILabel *expLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(expImgView)+ScalePS(5), StartY(birImgView), ScalePS(60), ScalePS(17)) text:infoModel.experience_cn textColor:COLOR_OF_WHITE font:Font_12];
    [topBgView addSubview:expLbl];
    
    UILabel *jobLbl = [UIToolsControl initLabelWithFrame:CGRectMake(20*Scale, EndY(topBgLineView)+40*Scale, 250*Scale, 25*Scale) text:[NSString stringWithFormat:@"曾任：%@", infoModel.position] textColor:COLOR_OF_WHITE font:Font_13];
    [topBgView addSubview:jobLbl];
    
    UILabel *phoneLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(jobLbl), EndY(jobLbl), ViewWidth(jobLbl), ViewHeight(jobLbl)) text:[NSString stringWithFormat:@"电话：%@", infoModel.telephone] textColor:COLOR_OF_WHITE font:Font_13];
    [topBgView addSubview:phoneLbl];
    
    UILabel *emailLbl = [UIToolsControl initLabelWithFrame:CGRectMake(StartX(jobLbl), EndY(phoneLbl), ViewWidth(jobLbl), ViewHeight(jobLbl)) text:[NSString stringWithFormat:@"邮箱：%@", infoModel.email] textColor:COLOR_OF_WHITE font:Font_13];
    [topBgView addSubview:emailLbl];
    
    if (self.showChatSettingFlag) {
        UIView *wxQRBgView = [UIToolsControl initViewWithFrame:CGRectMake(ViewWidth(topBgView)-ScalePS(80), EndY(topBgLineView)+ScalePS(15), ScalePS(60), ScalePS(60)) backgroundColor:COLOR_OF_WHITE];
        wxQRBgView.layer.cornerRadius = ScalePS(8);
        wxQRBgView.layer.masksToBounds = YES;
        [topBgView addSubview:wxQRBgView];
        
        UIImageView *wxQRImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(3*Scale, 3*Scale, 54*Scale, 54*Scale) imageName:@"wx_bg"];
        wxQRImgView.userInteractionEnabled = NO;
        [wxQRBgView addSubview:wxQRImgView];
        if (infoModel.weixin_img && infoModel.weixin_img.length) {
            [wxQRImgView sd_setImageWithURL:[NSURL URLWithString:infoModel.weixin_img]];
            if (self.canShowImg) {
                wxQRImgView.userInteractionEnabled = YES;
                UITapGestureRecognizer *wxQRImgViewTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(wxQRImgViewTapGesClick)];
                [wxQRImgView addGestureRecognizer:wxQRImgViewTapGes];
            }
        }
        
        UILabel *wxIDLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ViewWidth(topBgView)-100*Scale, EndY(wxQRImgView), 100*Scale, ScalePS(40)) text:[NSString stringWithFormat:@"微信：\n%@", infoModel.weixin] textColor:COLOR_OF_WHITE font:Font_12];
        wxIDLbl.textAlignment = NSTextAlignmentCenter;
        wxIDLbl.numberOfLines = 0;
        [topBgView addSubview:wxIDLbl];
    }
    
    UILabel *specialtyLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(topBgView)+20*Scale, 200, 25*Scale) text:@"自我描述" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    specialtyLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:specialtyLbl];
    
    NSMutableParagraphStyle *paragraphStyle111 = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle111 setLineSpacing:LineSpacingHeight*2];
    NSInteger specialtyHeight = ceil([((infoModel.specialty)?infoModel.specialty:@"待完善") boundingRectWithSize:CGSizeMake(WIDTH-60*Scale, MAXFLOAT) options:(NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:Font(Font_13), NSParagraphStyleAttributeName:paragraphStyle111} context:nil].size.height)+1;
//    CGFloat specialtyHeight = [UIToolsControl textHeightWithLineSpacing:((infoModel.specialty)?infoModel.specialty:@"待完善") size:CGSizeMake(WIDTH-60*Scale, MAXFLOAT) font:Font_13]+1;
    UILabel *specialtyContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(specialtyLbl)+10*Scale, WIDTH-60*Scale, specialtyHeight) text:nil textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    specialtyContentLbl.numberOfLines = 0;
    specialtyContentLbl.lineBreakMode = NSLineBreakByWordWrapping;
    [bottomScrollView addSubview:specialtyContentLbl];
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineSpacing = LineSpacingHeight*2;
    specialtyContentLbl.attributedText = [[NSAttributedString alloc] initWithString:((infoModel.specialty)?infoModel.specialty:@"待完善") attributes:@{NSFontAttributeName:Font(Font_13), NSParagraphStyleAttributeName:paraStyle}];
    
    UIView *specialtyLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, EndY(specialtyContentLbl)+20*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:specialtyLine];
    
    UILabel *currentCNLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(specialtyLine)+15*Scale, 200, 25*Scale) text:@"求职状态" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    currentCNLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:currentCNLbl];
    
    UILabel *currentCNContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(currentCNLbl)+10*Scale, 200, 20*Scale) text:((infoModel.current_cn)?infoModel.current_cn:@"待完善") textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [bottomScrollView addSubview:currentCNContentLbl];
    
    UIView *currentCNLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, EndY(currentCNContentLbl)+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:currentCNLine];
    
    UILabel *intentionLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(currentCNLine)+15*Scale, 200, 25*Scale) text:@"求职意向" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    intentionLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:intentionLbl];
    
    UILabel *intentionContentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(intentionLbl)+10*Scale, WIDTH-60*Scale, 20*Scale) text:[NSString stringWithFormat:@"%@ %@", ((infoModel.intentionModel.jobs_cn)?infoModel.intentionModel.jobs_cn:@"待完善"), ((infoModel.intentionModel.wage_cn)?infoModel.intentionModel.wage_cn:@"")] textColor:THEMECOLOR_OF_TEXT_333333 font:Font_15];
    intentionContentLbl.font = FontBold(Font_15);
    [bottomScrollView addSubview:intentionContentLbl];
    
    UILabel *intentionCityLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(intentionContentLbl)+10*Scale, WIDTH-60*Scale, 20*Scale) text:[NSString stringWithFormat:@"%@ %@", infoModel.intentionModel.district_cn, infoModel.intentionModel.trade_cn] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
    [bottomScrollView addSubview:intentionCityLbl];
    
    UIView *intentionLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, EndY(intentionCityLbl)+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:intentionLine];
    
    UILabel *workLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(intentionLine)+15*Scale, 200, 25*Scale) text:@"工作经历" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    workLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:workLbl];
    
    CGFloat workEndy = EndY(workLbl);
    for (NSInteger i = 0; i < infoModel.workArray.count; i++) {
        PMineResumeWorkInfoModel *temoModel = infoModel.workArray[i];
        ResumeWorkCell *cell = [[ResumeWorkCell alloc] initWithFrame:CGRectMake(30*Scale, workEndy, WIDTH-60*Scale, temoModel.allHeightOfCompanyLook) type:ResumeWorkCellTypeOfTwoTextDetailImg text:temoModel.company_name detailText:temoModel.job_name time:[NSString stringWithFormat:@"%@-%@", temoModel.start_date, ((temoModel.end_date&&temoModel.end_date.length)?temoModel.end_date:@"至今")] content:temoModel.desc imgs:temoModel.imgs];
        workEndy += temoModel.allHeightOfCompanyLook;
        [bottomScrollView addSubview:cell];
    }
    
    UIView *workLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, workEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:workLine];
    
    UILabel *educationLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(workLine)+15*Scale, 200, 25*Scale) text:@"教育经历" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    educationLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:educationLbl];
    
    CGFloat educationEndy = EndY(educationLbl);
    for (NSInteger i = 0; i < infoModel.educationArray.count; i++) {
        PMineResumeEducationInfoModel *temoModel = infoModel.educationArray[i];
        ResumeWorkCell *cell = [[ResumeWorkCell alloc] initWithFrame:CGRectMake(30*Scale, educationEndy, WIDTH-60*Scale, temoModel.allHeightOfCompanyLook) type:ResumeWorkCellTypeOfTwoTextImg text:temoModel.school detailText:[NSString stringWithFormat:@"%@ %@", temoModel.speciality, temoModel.education_cn] time:[NSString stringWithFormat:@"%@-%@", temoModel.start_date, ((temoModel.end_date&&temoModel.end_date.length)?temoModel.end_date:@"至今")] content:nil imgs:temoModel.imgs];
        educationEndy += temoModel.allHeightOfCompanyLook;
        [bottomScrollView addSubview:cell];
    }
    
    UIView *trainingLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, educationEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:trainingLine];
    
    UILabel *trainingLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(trainingLine)+15*Scale, 200, 25*Scale) text:@"培训经历" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    trainingLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:trainingLbl];
    
    CGFloat trainingEndy = EndY(trainingLbl);
    for (NSInteger i = 0; i < infoModel.trainingArray.count; i++) {
        PMineResumeTrainingInfoModel *temoModel = infoModel.trainingArray[i];
        ResumeWorkCell *cell = [[ResumeWorkCell alloc] initWithFrame:CGRectMake(30*Scale, trainingEndy, WIDTH-60*Scale, temoModel.allHeightOfCompanyLook) type:ResumeWorkCellTypeOfTwoTextDetailImg text:temoModel.agency detailText:temoModel.course time:[NSString stringWithFormat:@"%@-%@", temoModel.start_date, ((temoModel.end_date&&temoModel.end_date.length)?temoModel.end_date:@"至今")] content:temoModel.desc imgs:temoModel.imgs];
        trainingEndy += temoModel.allHeightOfCompanyLook;
        [bottomScrollView addSubview:cell];
    }
    
    UIView *projectLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, trainingEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:projectLine];
    
    UILabel *projectLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(projectLine)+15*Scale, 200, 25*Scale) text:@"项目经验" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    projectLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:projectLbl];
    
    CGFloat projectEndy = EndY(projectLbl);
    for (NSInteger i = 0; i < infoModel.projectArray.count; i++) {
        PMineResumeProjectInfoModel *temoModel = infoModel.projectArray[i];
        ResumeWorkCell *cell = [[ResumeWorkCell alloc] initWithFrame:CGRectMake(30*Scale, projectEndy, WIDTH-60*Scale, temoModel.allHeightOfCompanyLook) type:ResumeWorkCellTypeOfOneTextDetailImg text:temoModel.name detailText:nil time:[NSString stringWithFormat:@"%@-%@", temoModel.start_date, ((temoModel.end_date&&temoModel.end_date.length)?temoModel.end_date:@"至今")] content:temoModel.desc imgs:temoModel.imgs];
        projectEndy += temoModel.allHeightOfCompanyLook;
        [bottomScrollView addSubview:cell];
    }
    
    UIView *credentLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, projectEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:credentLine];
    
    UILabel *credentLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(credentLine)+15*Scale, 200, 25*Scale) text:@"获得证书" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    credentLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:credentLbl];
    
    CGFloat credentEndy = EndY(credentLbl);
    for (NSInteger i = 0; i < infoModel.credentArray.count; i++) {
        PMineResumeCredentInfoModel *temoModel = infoModel.credentArray[i];
        ResumeWorkCell *cell = [[ResumeWorkCell alloc] initWithFrame:CGRectMake(30*Scale, credentEndy, WIDTH-60*Scale, temoModel.allHeightOfCompanyLook) type:ResumeWorkCellTypeOfOneTextImg text:temoModel.name detailText:nil time:temoModel.recieve_date content:nil imgs:@[temoModel.img]];
        credentEndy += temoModel.allHeightOfCompanyLook;
        [bottomScrollView addSubview:cell];
    }
    
    UIView *languageLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, credentEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:languageLine];
    
    UILabel *languageLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(languageLine)+15*Scale, 200, 25*Scale) text:@"语言能力" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    languageLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:languageLbl];
    
    CGFloat languageContenntEndy = EndY(languageLbl);
    for (NSInteger i = 0; i < infoModel.languageArray.count; i++) {
        PMineResumeLanguageInfoModel *temoModel = infoModel.languageArray[i];
        UILabel *languageContenntLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, languageContenntEndy, 200, 25*Scale) text:[NSString stringWithFormat:@"%@ %@", temoModel.language_cn, temoModel.level_cn] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
        languageContenntEndy += 25*Scale;
        [bottomScrollView addSubview:languageContenntLbl];
    }
    
    UIView *tagsLine = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, languageContenntEndy+10*Scale, WIDTH-60*Scale, lineH) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    [bottomScrollView addSubview:tagsLine];
    
    UILabel *tagsLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(tagsLine)+15*Scale, 200, 25*Scale) text:@"特长标签" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_18];
    tagsLbl.font = FontBold(Font_18);
    [bottomScrollView addSubview:tagsLbl];
    
    CGFloat tagsEndy = EndY(tagsLbl);
    if (infoModel && infoModel.tags.count) {
        UIScrollView *tagsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30*Scale, tagsEndy+5*Scale, WIDTH-60*Scale, 35*Scale)];
        [bottomScrollView addSubview:tagsScrollView];
        tagsEndy += 40*Scale;
        CGFloat lblWidth = (WIDTH-70*Scale)*0.2;
        CGFloat endX = 0;
        for (NSInteger i = 0; i < infoModel.tags.count; i++) {
            CGFloat textWidth = [UIToolsControl textWidth:infoModel.tags[i] size:CGSizeMake(MAXFLOAT, CompanyTagsHeight) font:Font_13]+1;
            CGFloat width = ((lblWidth>textWidth)?lblWidth:textWidth);
            UILabel *lbl = [UIToolsControl initLabelWithFrame:CGRectMake(endX, 5*Scale, width, CompanyTagsHeight) text:infoModel.tags[i] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
            lbl.textAlignment = NSTextAlignmentCenter;
            lbl.layer.cornerRadius = 2*Scale;
            lbl.layer.masksToBounds = YES;
            lbl.layer.borderColor = THEMECOLOR_OF_TEXT_cccccc.CGColor;
            lbl.layer.borderWidth = 0.5;
            [tagsScrollView addSubview:lbl];
            lbl.adjustsFontSizeToFitWidth = YES;
            endX = EndX(lbl)+5*Scale;
        }
        tagsScrollView.contentSize = CGSizeMake(endX+15*Scale, 0);
    }
    
    bottomScrollView.contentSize = CGSizeMake(0, tagsEndy+20*Scale);
    
    if (self.canShowImg) {
        showImgView = [[ShowImgView alloc] initWithTarget:self];
        showImgView.hidden = YES;
    }
}
#pragma mark UINavigationControllerDelegate methods
//- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
//    if ([fromVC isKindOfClass:[WorkerResumeDetailViewController class]] && [toVC isKindOfClass:[CompanyHomeViewController class]]) {
//        CTransitionToPListVC *transitionVC = [[CTransitionToPListVC alloc] init];
//        return transitionVC;
//    } else {
//        return nil;
//    }
//}
#pragma mark UIGestureRecognizer handlers
- (void)handlePopRecognizer:(UIScreenEdgePanGestureRecognizer*)recognizer {
    CGFloat progress = [recognizer translationInView:self.view].x / (self.view.bounds.size.width * 1.0);
    progress = MIN(1.0, MAX(0.0, progress));
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        self.interactivePopTransition = [[UIPercentDrivenInteractiveTransition alloc] init];
        [self.navigationController popViewControllerAnimated:YES];
    } else if (recognizer.state == UIGestureRecognizerStateChanged) {
        [self.interactivePopTransition updateInteractiveTransition:progress];
    } else if (recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
        if (progress > 0.5) {
            [self.interactivePopTransition finishInteractiveTransition];
        } else {
            [self.interactivePopTransition cancelInteractiveTransition];
        }
        self.interactivePopTransition = nil;
    }
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self.view];
    CGPoint location = [gestureRecognizer locationInView:self.view];
    if (velocity.x > 0.0f&&(int)location.x%(int)[UIScreen mainScreen].bounds.size.width<60) {
        return NO;
    }
    return YES;
}

@end
